# server.port

- **Type:** `number`
- **Default:** `3000`

Specify a port number for Rsbuild Server to listen.

By default, Rsbuild Server listens on port `3000` and automatically increments the port number when the port is occupied. If you enable the [server.strictPort](/config/server/strict-port) config, Rsbuild Server will throw an error instead of incrementing the port number when the port is occupied.

Rsbuild CLI provides the [--port](/guide/basic/cli#rsbuild-dev) option to set the port number, and the `--port` option has higher priority than `server.port` config.

```bash
npx rsbuild dev --port 8080
```

## Example

Set the port to `8080`:

```ts
export default {
  server: {
    port: 8080,
  },
};
```

Set different port numbers for development and preview servers:

```ts
export default {
  server: {
    port: process.env.NODE_ENV === 'development' ? 3000 : 8080,
  },
};
```
